package com.shopcart.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "shop_cart")
public class Cart implements java.io.Serializable {

	private static final long serialVersionUID = -7739931496351140920L;

	@Id
	@GeneratedValue
	private Long id;
	
	public Date date;
	
	@OneToMany(fetch = FetchType.EAGER)
	private List<CartItem> items = new ArrayList<CartItem>();
	
	@OneToOne
	private Customer customer;

	/** Creates a new instance of Customer */
	public Cart() {
	}

	public Cart(Long id, List<CartItem> items, Customer customer) {
		this.id = id;
		this.items = items;
		this.customer = customer;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public List<CartItem> getItems() {
		return items;
	}

	public void setItems(List<CartItem> items) {
		this.items = items;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	
	public Date getDate() {
		return date;
	}
	
	public void setDate(Date date) {
		this.date = date;
	}
}